home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #1 / Ham Radio 2000.iso / ham2000 / tcp_ip / wnos / wn941101 / config.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-10-08  |  17.2 KB  |  714 lines

  1. #include "hardware.h"    /***/
  2. /* Stuff heavily dependent on the configuration info in config.h */
  3. #define OS2
  4.  
  5. #include <stdio.h>
  6. #include <dos.h>
  7. #include <ctype.h>
  8. #include <conio.h>
  9. #include "global.h"
  10. #include "mbuf.h"
  11. #include "proc.h"
  12. #include "cmdparse.h"
  13. #include "config.h"
  14. #include "daemon.h"
  15. #include "timer.h"
  16. #include "iface.h"
  17. #include "pktdrvr.h"
  18. #include "slip.h"
  19. #include "usock.h"
  20. #include "kiss.h"
  21. #ifdef ETHER
  22. #include "enet.h"
  23. #endif
  24. #include "ax25.h"
  25. #ifdef NETROM
  26. #include "netrom.h"
  27. #include "nr4.h"
  28. #endif
  29. #include "arp.h"
  30. #include "ip.h"
  31. #include "icmp.h"
  32. #include "tcp.h"
  33. #include "udp.h"
  34. #include "commands.h"
  35. #ifdef ARCNET
  36. #include "arcnet.h"
  37. #endif
  38.  
  39. static int dostart __ARGS((int argc,char *argv[],void *p));
  40. static int dostop __ARGS((int argc,char *argv[],void *p));
  41. static int dowrite __ARGS((int argc,char *argv[],void *p));
  42.  
  43. #ifdef MDEBUG
  44. extern int domdump __ARGS((int argc,char *argv[],void *p));
  45. #endif
  46.  
  47. #ifdef OS2
  48. static int domtask __ARGS((int argc,char *argv[],void *p));
  49. #endif
  50.  
  51. struct mbuf *Hopper;
  52. unsigned Nsessions = NSESSIONS;
  53.  
  54. /* Free memory threshold, below which things start to happen to conserve
  55.  * memory, like garbage collection, source quenches and refusing connects
  56.  */
  57. int32 Memthresh = (long)MTHRESH;        /* to be sure - db3fl */
  58.  
  59. /* Transport protocols atop IP */
  60. struct iplink Iplink[] = {
  61.     TCP_PTCL,    tcp_input,
  62.     UDP_PTCL,    udp_input,
  63.     ICMP_PTCL,    icmp_input,
  64. #if (defined (AX25) && defined (AXIP))
  65.     AX25_PTCL,    axip_input,
  66. #endif
  67.     IP_PTCL,    ipip_recv,
  68.     0,        0
  69. };
  70.  
  71. /* Transport protocols atop ICMP */
  72. struct icmplink Icmplink[] = {
  73.     TCP_PTCL,    tcp_icmp,
  74.     0,        0
  75. };
  76.  
  77. /* ARP protocol linkages */
  78. struct arp_type Arp_type[NHWTYPES] = {
  79. #ifdef    NETROM
  80.     AXALEN, 0, 0, 0, NULLCHAR, pax25, setcall,    /* ARP_NETROM */
  81. #else
  82.     0, 0, 0, 0, NULLCHAR,0,0,
  83. #endif
  84.  
  85. #ifdef    ETHER
  86.     EADDR_LEN,IP_TYPE,ARP_TYPE,1,Ether_bdcst,pether,gether, /* ARP_ETHER */
  87. #else
  88.     0, 0, 0, 0, NULLCHAR,0,0,
  89. #endif
  90.  
  91.     0, 0, 0, 0, NULLCHAR,0,0,        /* ARP_EETHER */
  92.  
  93. #ifdef    AX25
  94.     AXALEN, PID_IP, PID_ARP, PENDTIME, Ax25multi[0], pax25, setcall,
  95. #else
  96.     0, 0, 0, 0, NULLCHAR,0,0,        /* ARP_AX25 */
  97. #endif
  98.  
  99.     0, 0, 0, 0, NULLCHAR,0,0,        /* ARP_PRONET */
  100.  
  101.     0, 0, 0, 0, NULLCHAR,0,0,        /* ARP_CHAOS */
  102.  
  103.     0, 0, 0, 0, NULLCHAR,0,0,        /* ARP_IEEE802 */
  104.  
  105. #ifdef    ARCNET
  106.     AADDR_LEN, ARC_IP, ARC_ARP, 1, ARC_bdcst, parc, garc, /* ARP_ARCNET */
  107. #else
  108.     0, 0, 0, 0, NULLCHAR,0,0,
  109. #endif
  110.  
  111.     0, 0, 0, 0, NULLCHAR,0,0,        /* ARP_APPLETALK */
  112. };
  113.  
  114. extern void garbage __ARGS((int i, void *v1, void *v2));
  115.  
  116. /* daemons to be run at startup time */
  117. struct daemon Daemons[] = {
  118.     "killer",    512,    killer,
  119.     "timer",    2048,    timerproc,
  120.     "network",    4096,    network,
  121.     "keyboard",    512,    keyboard,
  122.     "status",    512,    statusline,
  123.     NULLCHAR,    0,        NULLVFP
  124. };
  125.  
  126. struct iftype Iftypes[] = {
  127.     /* This entry must be first, since Loopback refers to it */
  128.     "None", 0, 0, 0, 0,    CL_NONE, 0,
  129.  
  130. #ifdef    AX25
  131.     "AX25",ax_send,ax_output,pax25,setcall,CL_AX25,AXALEN,
  132. #endif
  133.  
  134. #ifdef    SLIP
  135.     "SLIP",slip_send,0,0,0,CL_NONE,0,
  136. #endif
  137.  
  138. #ifdef    ETHER
  139.     /* Note: NULL is specified for the scan function even though
  140.      * gether() exists because the packet drivers don't support
  141.      * address setting.
  142.      */
  143.     "Ethernet",enet_send,enet_output,pether,0,CL_ETHERNET,EADDR_LEN,
  144. #endif
  145.  
  146. #ifdef    NETROM
  147.     "NETROM",nr_send,0,pax25,setcall,CL_NETROM,AXALEN,
  148. #endif
  149.  
  150. #ifdef    SLFP
  151.     "SLFP",pk_send,NULL,NULL,NULL,CL_NONE,0,
  152. #endif
  153.     NULLCHAR
  154. };
  155.  
  156. /* Command lookup and branch tables */
  157. struct cmds Cmds[] = {
  158.     /* The "go" command must be first */
  159.     "",            go,            0, 0, NULLCHAR,
  160. #ifdef MDEBUG
  161.     ".",        domdump,    0, 0, NULLCHAR,
  162. #endif
  163. #ifndef    AMIGA
  164.     "!",        doshell,    0, 0, NULLCHAR,
  165. #endif
  166.     "abort",    doabort,    0, 0, NULLCHAR,
  167. #ifdef    AMIGA
  168.     "amiga",    doamiga,    0, 0, NULLCHAR,
  169. #endif
  170. #if    (defined(MAC) && defined(APPLETALK))
  171.     "applestat",    doatstat,    0,    0, NULLCHAR,
  172. #endif
  173. #if    (defined(AX25) || defined(ETHER) || defined(APPLETALK))
  174.     "arp",        doarp,        0, 0, NULLCHAR,
  175. #endif
  176. #ifdef    ASY
  177.     "asystat",    doasystat,    0, 0, NULLCHAR,
  178. #endif
  179.     "attach",    doattach,    0, 2, "attach <hardware> <hw specific options>",
  180.     "attended",    doattended,    0, 0, NULLCHAR,
  181.     "attribute",doattribute,0, 2, "attribute <color|mono>",
  182. #ifdef    AX25
  183.     "ax25",        doax25,        0, 0, NULLCHAR,
  184. #endif
  185. #ifdef    MAILBOX
  186.     "bbs",        dobbs,        1024, 0, NULLCHAR,
  187. #endif
  188.     "bell",        dobell,        0, 0, NULLCHAR,
  189. /* This one is out of alpabetical order to allow abbreviation to "c" */
  190. #ifdef    AX25
  191.     "connect",  doconnect,  1024, 2, "connect [<iface>] <call>",
  192. #endif
  193.     "chat",        dochat,        1024, 2, "chat <host>",
  194. #if    !defined(UNIX) && !defined(AMIGA)
  195.     "cd",        docd,        0, 0, NULLCHAR,
  196. #endif
  197.     "close",    doclose,    0, 0, NULLCHAR,
  198. /*
  199.     "dial",        dodial,        0, 3,"dial <iface> <dial-string>",
  200. */
  201. #ifndef    AMIGA
  202.     "dir",        dodir,        1024, 0, NULLCHAR, /* note sequence */
  203. #endif
  204.     "delete",    dodelete,    0, 2, "delete <file>",
  205.     "detach",    dodetach,    0, 2, "detach <iface>",
  206.     "domain",    dodomain,    0, 0, NULLCHAR,
  207. #ifdef    DRSI
  208.     "drsistat",    dodrstat,    0, 0, NULLCHAR,
  209. #endif
  210. #ifdef MDEBUG
  211.     "dump",        domdump,    0, 0, NULLCHAR,
  212. #endif
  213.     "echo",        doecho,        0, 0, NULLCHAR,
  214.     "eol",        doeol,        0, 0, NULLCHAR,
  215.     "escape",    doescape,    0, 0, NULLCHAR,
  216. #ifdef    PC_EC
  217.     "etherstat",    doetherstat,    0, 0, NULLCHAR,
  218. #endif
  219.     "exit",        doexit,        0, 0, NULLCHAR,
  220.     "finger",    dofinger,    1024, 2, "finger <name|[@<host>]>",
  221.     "ftp",        doftp,        1536, 2, "ftp <host>",
  222.     "ftype",    doftype,    0, 0, NULLCHAR,
  223.     "ftptdisc",    doftptdisc,    0, 0, NULLCHAR,
  224.     "help",        dohelp,        0, 0, NULLCHAR,
  225.     "hostname",    dohostname,    0, 0, NULLCHAR,
  226.     "icmp",        doicmp,        0, 0, NULLCHAR,
  227.     "ifconfig",    doifconfig,    0, 0, NULLCHAR,
  228.     "ip",        doip,        0, 0, NULLCHAR,
  229.     "kick",        dokick,        0, 0, NULLCHAR,
  230.     "log",        dolog,        0, 0, NULLCHAR,
  231. #ifdef LZW
  232.     "lzw",        dolzw,        0, 2, "lzw <bits|mode>",
  233. #endif
  234.     "mail",        dobmail,    0, 0, NULLCHAR,
  235. #ifdef    MAILBOX
  236.     "mbox",        dombox,        0, 0, NULLCHAR,
  237. #endif
  238.     "mem",        domem,        0, 0, NULLCHAR,
  239.     "mkdir",    domkd,        0, 2, "mkdir <dir>",
  240. #ifdef    AX25
  241.     "mode",        domode,        0, 2, "mode <host> [mode]",
  242. #endif
  243.     "more",        domore,        768, 2, "more <file>",
  244.     "motd",        domotd,        0, 0, NULLCHAR,
  245. #ifdef OS2
  246.     "mtask",    domtask,    0, 0, NULLCHAR,
  247. #endif
  248. #ifdef    NETROM
  249.     "netrom",    donetrom,    0, 0, NULLCHAR,
  250. #endif
  251. #ifdef    NNTP
  252.     "nntp",        donntp,        0, 0, NULLCHAR,
  253. /*    "nntpview",    donntpview,    0, 0, NULLCHAR, */
  254. #endif
  255. #ifdef    NRS
  256.     "nrstat",    donrstat,    0, 0, NULLCHAR,
  257. #endif
  258.     "param",    doparam,    0, 2, "param <iface>",
  259.     "ping",        doping,        1024, 2, "ping <host> <length> <interval> <incflag>",
  260. #ifdef POP2_CLIENT
  261.     "pop",        dopop2,        0, 0, NULLCHAR,
  262.     "pop2",        dopop2,        0, 0, NULLCHAR,
  263. #endif
  264. #ifdef POP2_CLIENT
  265.     "pop3",        dopop3,        0, 0, NULLCHAR,
  266. #endif
  267.     "ps",        ps,            0, 0, NULLCHAR,
  268. #if    !defined(UNIX) && !defined(AMIGA)
  269.     "pwd",        docd,        0, 0, NULLCHAR,
  270. #endif
  271. #ifdef RARP
  272. #if    (defined(AX25) || defined(ETHER))
  273.     "rarp",        dorarp,        0, 0, NULLCHAR,
  274. #endif
  275. #endif /* RARP */
  276.     "record",    dorecord,    0, 0, NULLCHAR,
  277.     "remote",    doremote,    0, 3, "remote [-p port] [-k key] [-a kickaddr] <host> exit|reset|kick",
  278.     "rename",    dorename,    0, 3, "rename <oldfile> <newfile>",
  279.     "reset",    doreset,    0, 0, NULLCHAR,
  280.     "resetping",    doresetping,    0, 2, "resetping <target>",
  281.     "rmdir",    dormd,        0, 2, "rmdir <dir>",
  282.     "route",    doroute,    0, 0, NULLCHAR,
  283.     "session",    dosession,    0, 0, NULLCHAR,
  284.     "save",        dosavefile,     0, 0, NULLCHAR,
  285.     "setping",    dosetping,    0, 0, NULLCHAR,
  286. #ifdef RLOGINCLI
  287.         "rlogin",       dorlogin,       2048,   2,  "rlogin <address>",
  288.         "rloguserid",   dorloguser,     0, 0,   NULLCHAR,
  289. #endif
  290. #ifdef    SCC
  291.     "sccstat",    dosccstat,    0, 0, NULLCHAR,
  292. #endif
  293. #if    !defined(AMIGA)
  294.     "shell",    doshell,    0, 0, NULLCHAR,
  295. #endif
  296.     "smtp",        dosmtp,        0, 0, NULLCHAR,
  297.     "socket",    dosock,        0, 0, NULLCHAR,
  298.     "source",    dosource,    0, 2, "source <file>",
  299. #ifdef    SERVERS
  300.     "start",    dostart,    0, 2, "start <server>",
  301. #endif
  302.     "status",    dostatus,    0, 0, NULLCHAR,
  303. #ifdef  SERVERS
  304.     "stop",        dostop,        0, 2, "stop <server>",
  305. #endif
  306.     "swap",        doswap,        0, 0, NULLCHAR,
  307. #ifdef MAILBOX
  308.     "setsysop",    dosysopset, 0, 2, "<secret number>",
  309.     "sysop",    dormncsys,    0, 2, "<number>",
  310. #endif
  311.     "tcp",        dotcp,        0, 0, NULLCHAR,
  312.     "tail",        dotail,        0, 2, "tail <file>",
  313.     "telnet",    dotelnet,    1024, 2, "telnet <host>",
  314. #ifdef    MAILBOX
  315.     "thirdparty",    dothirdparty,    0, 0, NULLCHAR,
  316. #endif
  317. #ifdef ASY
  318.     "tip",        dotip,        1024, 2, "tip <iface>",
  319. #endif
  320. #ifdef    TRACE
  321.     "trace",    dotrace,    0, 0, NULLCHAR,
  322. #endif
  323.     "udp",        doudp,        0, 0, NULLCHAR,
  324.     "upload",    doupload,    0, 0, NULLCHAR,
  325. #if defined(MSDOS) && defined (XXX)
  326.     "watch",    doswatch,    0, 0, NULLCHAR,
  327. #endif
  328.     "wrap",        dowrap,        0, 0, NULLCHAR,
  329.     "write",    dowrite,    0, 2, "write <socket> <msg>",
  330.     "?",        dohelp,        0, 0, NULLCHAR,
  331.     NULLCHAR,    NULLFP,        0, 0, "Invalid command. Try HELP.",
  332. };
  333.  
  334. /* Functions to be called on each clock tick */
  335. void (*Cfunc[])() = {
  336.     pctick,        /* Call PC-specific stuff to keep time */
  337.     kbint,        /* Necessary because there's no hardware keyboard interrupt */
  338.     refiq,        /* Replenish interrupt pool */
  339. #ifdef    ASY
  340.     asytimer,
  341. #endif
  342. #ifdef    SCC
  343.     scctimer,
  344. #endif
  345.     0,
  346. };
  347.  
  348. /* Packet tracing stuff */
  349. #ifdef    TRACE
  350. #include "trace.h"
  351.  
  352. /* Protocol tracing function pointers. Matches list of class definitions
  353.  * in pktdrvr.h.
  354.  */
  355. struct trace Tracef[] = {
  356.     NULLFP,            ip_dump,        /* CL_NONE */
  357. #ifdef    ETHER
  358.     ether_forus,    ether_dump,        /* CL_ETHERNET */
  359. #else
  360.     NULLFP,        NULLVFP,
  361. #endif
  362.     NULLFP,            NULLVFP,        /* CL_PRONET_10 */
  363.     NULLFP,            NULLVFP,        /* CL_IEEE8025 */
  364.     NULLFP,            NULLVFP,        /* CL_OMNINET */
  365. #ifdef    APPLETALK
  366.     at_forus,        at_dump,        /* CL_APPLETALK */
  367. #else
  368.     NULLFP,            NULLVFP,
  369. #endif
  370.     NULLFP,            ip_dump,        /* CL_SERIAL_LINE */
  371.     NULLFP,            NULLVFP,        /* CL_STARLAN */
  372. #ifdef    ARCNET
  373.     arc_forus,        arc_dump,        /* CL_ARCNET */
  374. #else
  375.     NULLFP,            NULLVFP,
  376. #endif
  377. #ifdef    AX25
  378.     ax_forus,        ax25_dump,        /* CL_AX25 */
  379. #else
  380.     NULLFP,            NULLVFP,
  381. #endif
  382. #ifdef    KISS                
  383.     ki_forus,        ki_dump,        /* CL_KISS */
  384. #else
  385.     NULLFP,            NULLVFP,
  386. #endif
  387.     NULLFP,            NULLVFP,        /* CL_IEEE8023 */
  388.     NULLFP,            NULLVFP,        /* CL_FDDI */
  389.     NULLFP,            NULLVFP,        /* CL_INTERNET_X25 */
  390.     NULLFP,            NULLVFP,        /* CL_LANSTAR */
  391.     NULLFP,            ip_dump,        /* CL_SLFP */
  392. #ifdef    NETROM
  393.     NULLFP,            ip_dump,        /* CL_NETROM */
  394. #else
  395.     NULLFP,            NULLVFP,
  396. #endif
  397.  
  398. };
  399. #else    /* TRACE */
  400. /* Stub for packet dump function */
  401. void
  402. dump(iface,direction,type,bp)
  403. struct iface *iface;
  404. int direction;
  405. unsigned type;
  406. struct mbuf *bp;
  407. {
  408. }
  409. void
  410. raw_dump(iface,direction,bp)
  411. struct iface *iface;
  412. int direction;
  413. struct mbuf *bp;
  414. {
  415. }
  416. #endif    /* TRACE */
  417.  
  418. /* Stub for routing timeout when RIP is not configured -- just remove entry */
  419. void
  420. rt_timeout(s)
  421. void *s;
  422. {
  423.     struct route *stale = (struct route *)s;
  424.  
  425.     rt_drop(stale->target,stale->bits);
  426. }
  427.  
  428. #ifdef    SERVERS
  429.  
  430. extern int xconv0 __ARGS((int argc,char *argv[],void *p));
  431. extern int xconv1 __ARGS((int argc,char *argv[],void *p));
  432.  
  433.  
  434. /* "start" and "stop" subcommands */
  435. static int
  436. dostart(argc,argv,p)
  437. int argc;
  438. char *argv[];
  439. void *p;
  440. {
  441.     struct cmds Startcmds[] = {
  442. #if    defined(AX25) && defined(MAILBOX)
  443.         "ax25",        ax25start,    256, 0, NULLCHAR,
  444. #endif
  445.         "chat",        ttylstart,    256, 0, NULLCHAR,
  446. #ifdef CONVERS
  447.         "convers",    conv1,        512, 0,    NULLCHAR,
  448. #endif
  449.         "discard",    dis1,        256, 0, NULLCHAR,
  450.         "domain",    dom1,        768, 0, NULLCHAR,
  451.         "echo",        echo1,        256, 0, NULLCHAR,
  452.         "finger",    finstart,    256, 0, NULLCHAR,
  453.         "ftp",        ftpstart,    256, 0, NULLCHAR,
  454. #if    defined(NETROM) && defined(MAILBOX)
  455.         "netrom",    nr4start,    256, 0, NULLCHAR,
  456. #endif
  457. #ifdef    NNTP
  458.         "nntp",     nntp1,        768, 0, NULLCHAR,
  459. #endif
  460. #ifdef POP2_SERVER
  461.         "pop",        pop1,        256, 0, NULLCHAR,
  462.         "pop2",        pop1,        256, 0, NULLCHAR,
  463. #endif
  464. #ifdef POP3_SERVER
  465.         "pop3",        pop3start,    256, 0, NULLCHAR,
  466. #endif
  467.         "smtp",        smtp1,        256, 0, NULLCHAR,
  468. #if    defined(MAILBOX)
  469.         "telnet",    telnet1,    256, 0, NULLCHAR,
  470. #endif
  471.         "ttylink",    ttylstart,    256, 0, NULLCHAR,
  472.         "remote",    rem1,        1024, 0, NULLCHAR,
  473. #if (defined(LZW) && defined(CONVERS))
  474.         "xconvers", xconv1,        512, 0, NULLCHAR,
  475. #endif
  476.         NULLCHAR,
  477.     };
  478.     return subcmd(Startcmds,argc,argv,p);
  479. }
  480.  
  481. static int
  482. dostop(argc,argv,p)
  483. int argc;
  484. char *argv[];
  485. void *p;
  486. {
  487.     struct cmds Stopcmds[] = {
  488. #if    defined(AX25) && defined(MAILBOX)
  489.         "ax25",        ax250,        0, 0, NULLCHAR,
  490. #endif
  491.         "chat",        ttyl0,        0, 0, NULLCHAR,
  492. #ifdef CONVERS
  493.         "convers",    conv0,        0, 0, NULLCHAR,
  494. #endif
  495.         "discard",    dis0,        0, 0, NULLCHAR,
  496.         "domain",    dom0,        0, 0, NULLCHAR,
  497.         "echo",        echo0,        0, 0, NULLCHAR,
  498.         "finger",    fin0,        0, 0, NULLCHAR,
  499.         "ftp",        ftp0,        0, 0, NULLCHAR,
  500. #if    defined(NETROM) && defined(MAILBOX)
  501.         "netrom",    nr40,        0, 0, NULLCHAR,
  502. #endif
  503. #ifdef NNTP
  504.         "nntp",        nntp0,        0, 0, NULLCHAR,
  505. #endif
  506. #ifdef POP2_SERVER
  507.         "pop",        pop0,        0, 0, NULLCHAR,
  508.         "pop2",        pop0,        0, 0, NULLCHAR,
  509. #endif
  510. #ifdef POP3_SERVER
  511.         "pop3",        pop3stop,    0, 0, NULLCHAR,
  512. #endif
  513.         "smtp",        smtp0,        0, 0, NULLCHAR,
  514. #ifdef    MAILBOX
  515.         "telnet",    telnet0,    0, 0, NULLCHAR,
  516. #endif
  517.         "ttylink",    ttyl0,        0, 0, NULLCHAR,
  518.         "remote",    rem0,        0, 0, NULLCHAR,
  519. #if (defined(LZW) && defined(CONVERS))
  520.         "xconvers", xconv0,        0, 0, NULLCHAR,
  521. #endif
  522.         NULLCHAR,
  523.     };
  524.     return subcmd(Stopcmds,argc,argv,p);
  525. }
  526. #endif    /* SERVERS */
  527.  
  528. /* Various configuration-dependent functions */
  529. /* Process packets in the Hopper */
  530. static void
  531. network(i,v1,v2)
  532. int i;
  533. void *v1;
  534. void *v2;
  535. {
  536.     struct mbuf *bp;
  537.     struct phdr phdr;
  538.     int i_state;
  539.  
  540.     for(;;) {
  541.         refiq();    /* Replenish interrupt buffer pool */
  542.  
  543.         i_state = dirps();
  544.         while(Hopper == NULLBUF)
  545.             pwait(&Hopper);
  546.         restore(i_state);
  547.  
  548.         /* Process the input packet */
  549.         bp = dequeue(&Hopper);
  550.         pullup(&bp,(char *)&phdr,sizeof(phdr));
  551.  
  552. #ifdef XXX
  553.         now in trace.c - DB3FL.920208
  554.         if(phdr.iface != NULLIF) {
  555.             phdr.iface->lastrecv = secclock();
  556.             phdr.iface->rawrecvcnt++;
  557.         }
  558. #endif
  559.  
  560.         dump(phdr.iface,IF_TRACE_IN,phdr.type,bp);
  561.  
  562.         switch(phdr.type){
  563. #ifdef    KISS
  564.         case CL_KISS:
  565.             kiss_recv(phdr.iface,bp);
  566.             break;
  567. #endif
  568. #ifdef    AX25
  569.         case CL_AX25:
  570.             ax_recv(phdr.iface,bp);
  571.             break;
  572. #endif
  573. #ifdef    ETHER
  574.         case CL_ETHERNET:
  575.             eproc(phdr.iface,bp);
  576.             break;
  577. #endif
  578. #ifdef ARCNET
  579.         case CL_ARCNET:
  580.             aproc(phdr.iface,bp);
  581.             break;
  582. #endif
  583.         /* These types have no link layer protocol at the point when they're
  584.          * put in the hopper, so they can be handed directly to IP. The
  585.          * separate types are just for user convenience when running the
  586.          * "iface" command.
  587.          */
  588.         case CL_NONE:
  589.         case CL_SERIAL_LINE:
  590.         case CL_SLFP:
  591.             ip_route(phdr.iface,phdr.iface,bp,0);
  592.             break;
  593.         default:
  594.             free_p(bp);
  595.             break;
  596.         }
  597.         /* Let everything else run - this keeps the system from wedging
  598.          * when we're hit by a big burst of packets
  599.          */
  600.         pwait(NULL);
  601.     }
  602. }
  603.  
  604. static int
  605. dowrite(argc,argv,p)
  606. int argc;
  607. char *argv[];
  608. void *p;
  609. {
  610.     char msg[256];
  611.     int count, i, sock[DEFNSOCK];
  612.  
  613.     count = (argc < DEFNSOCK - 1) ? argc : DEFNSOCK -1;
  614.  
  615.     /* get socket args */
  616.     for (i = 1; i < count; i++)
  617.         if((sock[i] = atoi(argv[i])) == 0)
  618.             break;
  619.  
  620.     count = i;
  621.     msg[0] = '\0';
  622.  
  623.     /* collect rest of args as message */
  624.     for (; i < argc; i++) {
  625.         strcat(msg,argv[i]);
  626.         strcat(msg," ");
  627.     }
  628.  
  629.     /* output to all sockets */
  630.     for (i = 1; i < count; i++)    {
  631.         usprintf(sock[i],"\n*** message from %s:\n%s\n",Hostname,msg);
  632.         usflush(sock[i]);
  633.     }
  634.     return 0;
  635. }
  636.  
  637. /* Attach an interface
  638.  * Syntax: attach <hw type> <I/O address> <vector> <mode> <label> <bufsize> [<speed>]
  639.  */
  640. static int
  641. doattach(argc,argv,p)
  642. int argc;
  643. char *argv[];
  644. void *p;
  645. {
  646.   /* List of supported hardware devices */
  647.   struct cmds Attab[] = {
  648. #ifdef  PC_EC
  649.     /* 3-Com Ethernet interface */
  650.     "3c500", ec_attach, 0, 7,
  651.     "attach 3c500 <address> <vector> arpa <label> <bufsize> <mtu> [<ip_address>]",
  652. #endif
  653. #ifdef  ASY
  654.     /* Ordinary PC asynchronous adaptor */
  655.     "asy", asy_attach, 0, 8,
  656. #ifndef AMIGA
  657.     "attach asy <address> <vector> slip|ax25|nrs <label> <bufsize> <mtu> <speed> <c|v>",
  658. #else
  659.     "attach asy <driver> <unit> slip|ax25|nrs <label> <bufsize> <mtu> <speed> <c|v>",
  660. #endif  /* AMIGA */
  661. #endif  /* ASY */
  662. #if defined(KISS) && (defined(ASY) || defined(SCC))
  663.     /* Multi-port KISS interface piggy-backing on ASY interface. */
  664.     "kiss", kiss_attach, 0, 4,
  665.     "attach kiss <asy_iface_label> <port> <label> [mtu]",
  666. #endif  /* KISS */
  667. #ifdef  DRSI
  668.     /* DRSI PCPA card in low speed mode */
  669.     "drsi", dr_attach, 0, 8,
  670.     "attach drsi <address> <vector> ax25 <label> <bufsize> <mtu> <speed_A>"
  671.     " [<speed_B> [<ip_address_A> [<ip_address_B>]]]",
  672. #endif
  673. #ifdef NETROM
  674.     /* fake netrom interface */
  675.     "netrom", nr_attach, 0, 1,
  676.     "attach netrom",
  677. #endif
  678. #ifdef  PACKET
  679.     /* FTP Software's packet driver spec */
  680.     "packet", pk_attach, 0, 4,
  681.     "attach packet <int#> <label> <bufsize> <mtu> [<ip_address>]",
  682. #endif
  683. #ifdef SCC
  684.     "scc", scc_attach, 0, 7,
  685.     "attach scc <devices> init <address> <spacing> <Aoff> <Boff> <Dataoff>\n"
  686.     "   <intack> <vector> [p|r]<clock> [hdwe] [param]\n"
  687.     "attach scc <channel> slip|ax25|nrs|kiss <label> <mtu> <speed> <bufsize>",
  688.   #endif
  689. #if (defined (AX25) && defined (AXIP))
  690.     "axip", axip_attach, 0, 3,
  691.     "attach axip <label> <mtu> <remote_host>",
  692. #endif
  693. #ifdef  VANESSA
  694.     "vanessa", van_attach, 0, 3,
  695.     "attach vanessa <label> <port#> [<mtu>]",
  696. #endif
  697.     NULLCHAR,
  698.   };
  699.  
  700.   return subcmd(Attab,argc,argv,p);
  701. }
  702.  
  703. #ifdef OS2
  704. static int
  705. domtask (int argc,char *argv[],void *p)
  706. {
  707.     if(argc > 1)
  708.         Mtasker = 4;
  709.     else
  710.         chktasker();
  711.     return 0;
  712. }
  713. #endif
  714.